package com.bgs.service.Impl;

import com.bgs.mapper.FragmentMapper;
import com.bgs.pojo.*;
import com.bgs.service.FragmentService;
import com.bgs.tool.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Slf4j
@Service
public class FragmentServiceImpl implements FragmentService {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Autowired
    FragmentMapper fragmentMapper;

    @Override
    public boolean rcdelete(Integer sid) {
        return fragmentMapper.rcdelete(sid);
    }

    @Override
    public boolean rcAdd(ScheduleVo scheduleVo) {

        return fragmentMapper.rcAdd(scheduleVo);
    }

    @Override
    public R findAllDateRc(LocalDateTime starttime) {
//        starttime.format()
        System.out.println(starttime.getYear()+""+starttime.getMonth()+""+starttime.getDayOfWeek());
//       减去8小时
        starttime=starttime.minusHours(8);
        List<ScheduleVo> list = fragmentMapper.findAllDateRc(starttime);
        return R.ok().data("data",list);
    }

    @Override
    public ScheduleVo findRC(Integer sid) {

        return fragmentMapper.findRC(sid);
    }

    @Override
    public boolean xgzt(ScheduleVo scheduleVo) {
        return fragmentMapper.xgzt(scheduleVo);
    }

    @Override
    public R findAllRc(String sname) {
        List<ScheduleVo> list = fragmentMapper.findAllRc(sname);
        return R.ok().data("data",list);
    }


    /*文档开始*/

    //    查看我的文档
    @Override
    public R findMyWd(String submitter) {
        List<DocxVo> list = fragmentMapper.findMyWd(submitter);
        return R.ok().data("data", list);
    }

    //    上传文档
    @Override
    public boolean addWD(DocxVo docxVo) {
        return fragmentMapper.addWD(docxVo);
    }

    //查看所有文档
    @Override
    public R findallwd(DocxVo docxVo) {
        List<DocxVo> list = fragmentMapper.findallwd(docxVo);
        return R.ok().data("data", list);
    }

    /*文档结束*/
    /*公告收藏*/
    @Override
    public boolean addGGSc(NoticcollectVo noticcollectVo) {
        return fragmentMapper.addGGSc(noticcollectVo);
    }

    @Override
    public boolean deleteGGSc(Integer noticeid) {
        return fragmentMapper.deleteGGSc(noticeid);
    }
    /*公告收藏结束*/

    /*新闻收藏开始*/
    @Override
    public boolean addXwSc(JourcollectVo jourcollectVo) {
        return fragmentMapper.addXwSc(jourcollectVo);
    }

    //删除收藏
    @Override
    public boolean deleteXwSc(Integer jourid) {
        return fragmentMapper.deleteXwSc(jourid);
    }

    /*新闻收藏结束*/
    /*新闻表开始*/
    //TYPE0
    @Override
    public R findxw0(JournalismVo journalismVo) {
        List<JournalismVo> list = fragmentMapper.findxw0(journalismVo);
        return R.ok().data("data", list);
    }

    //TYPE1
    @Override
    public R findxw1(JournalismVo journalismVo) {
        List<JournalismVo> list = fragmentMapper.findxw1(journalismVo);
        return R.ok().data("data", list);
    }

    //TYPE2
    @Override
    public R findxw2(JournalismVo journalismVo) {
        List<JournalismVo> list = fragmentMapper.findxw2(journalismVo);
        return R.ok().data("data", list);
    }

    //  展示所有新闻
    @Override
    public R hfindAllXinwen(JournalismVo journalismVo) {
        List<JournalismVo> list = fragmentMapper.hfindAllXinwen(journalismVo);
        return R.ok().data("data", list);
    }

    //   新闻详情根据id
    @Override
    public JournalismVo findxwID(Integer jourid) {
        return fragmentMapper.findxwID(jourid);
    }

    //    新闻名称搜索
    @Override
    public R findXinWenName(String theme) {
        List<JournalismVo> list = fragmentMapper.findXinWenName(theme);
        return R.ok().data("data", list);
    }

    // 修改num
    @Override
    public int updateNum(JournalismVo journalismVo) {
        return fragmentMapper.updateNum(journalismVo);
    }

    /*新闻表结束*/
    /*公告表*/
//   展示所有公告
    @Override
    public R hSelectAllgongao(NoticeVo noticeVo) {
        List<NoticeVo> list = fragmentMapper.hSelectAllgongao(noticeVo);
        return R.ok().data("data", list);
    }

    //公告搜索
    @Override
    public R findGonggaoName(String noticename) {
        List<NoticeVo> list = fragmentMapper.findGonggaoName(noticename);
        return R.ok().data("data", list);
    }

    //查询指定公告根据ID
    @Override
    public NoticeVo findgongaoId(Integer noticeid) {
//        List<NoticeVo> list = fragmentMapper.findgongaoId(noticeid);
        return fragmentMapper.findgongaoId(noticeid);
    }

    @Override
    public int updategongaoSum(NoticeVo noticeVo) {
        return fragmentMapper.updategongaoSum(noticeVo);
    }

    /*公告表结束*/


}
